package com.demohomework.homeworkdemo.mapper;

import com.demohomework.homeworkdemo.pojo.AssCorrect;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface AssCorrectMapper {


    @Select("SELECT * FROM ass_correct WHERE stu_id = #{id}")
    List<AssCorrect> list(Integer id);

    @Update("UPDATE ass_correct SET score = #{score},info = #{info} WHERE stu_id = #{stuId} AND ass_id = #{assId}")
    void update(AssCorrect assCorrect);

    @Insert("INSERT INTO ass_correct(stu_id,ass_id,score,info,update_at) VALUES(#{stuId},#{assId},#{score},#{info},now())")
    void add(AssCorrect assCorrect);

    @Select("SELECT COUNT(*) > 0 FROM ass_correct WHERE ass_id = #{assId} AND stu_id = #{stuId}")
    boolean existsByAssIdAndStuId(@Param("assId") int assId, @Param("stuId") int stuId);

}
